import requst from "../../utils/service.js";

//1. ;/3


//试卷创编 有id整体渲染
export let createrenderlink = (testId) => {
    return requst({
        url: `/test/searchOne/${testId}`,
        method: "get",
        params: {
            testId
        }
    })
}

// //试卷list 渲染接口 
export let testrenderlink = (page, limit) => {
    return requst({
        url: `/test/search`,
        method: "get",
        params: {
            page,
            limit
        }
    })
}

// //试卷list 查询接口 
export let testquerylink = (page,limit,testId, testClass, testSubjectName) => {
    return requst({
        url: `/test/search`,
        method: "get",
        params: {
            page,
            limit,
            testId,
            testClass,
            testSubjectName,
            
        }
    })
}

// //试卷list 删除接口 
export let testdellink = (testId) => {
    return requst({
        url: `/test/deleteOne/${testId}`,
        method: "delete",
        params: {
            testId,
        }
    })
}


///试卷list 新增接口  
export let testaddlink = () => {
    return requst({
        url: `/test/insertOne`,
        method: "post",

    })
}




//create--dialog//
//1.数据渲染+page
//2.查询+page
//3.根据id查询将dialog中的数据传送到试卷创编页面


//create--dialog//
//1.数据渲染+page----------------ok
export let dialogdatalink = (page, limit) => {
    return requst({
        url: "/timu/findAll",
        method: "get",
        params: {
            page,
            limit
        }
    })
}
//2.查询+page------------------有点问题
export let dialogquerylink = (page, limit, question_id, question_type) => {
    return requst({
        url: `/timu/findAll`,
        method: "get",
        params: {
            page,
            limit,
            question_id,
            question_type
        }
    })
}

//3.根据id查询将dialog中的数据传送到试卷创编页面
export let dialogrenderlink = (questionId) => {
    return requst({
        url: `/timu/yulan/${questionId}`,
        method: "get",
        params: {
            questionId
        }
    })
}

//4.试卷创编页面整体提交
export let createsubmitlink = (testClass, testSubjectName, testType, testName, questionContentList,testAnswerTime,testCreateTime) => {
    return requst({
        url: `/test/insertOne`,
        method: "post",
        data: {
            testClass,
            testSubjectName,
            testType,
            testName,
            questionContentList,
            testAnswerTime,
            testCreateTime
        }
        // headers:{
        //     "Content-type":"application/x-www-form-urlencoded",
        // }
    })
}


//题库
//一、题目列表
//1.分页
export let pagelink = (page, limit) => {
    return requst({
      url: "/timu/findAll",
      method: "get",
      params: {
        page,
        limit,
      },
    });
  };

//二、单选
//1.添加单选题
export let singlelink = (single, text) => {
    return requst({
      url: "/danxuan/insertOne",
      method: "post",
      data: {
        ...single,
        a: text[0],
        b: text[1],
        c: text[2],
        d: text[3],
      },
      headers: {
        "Content-type": "application/json; charset=utf-8",
      },
    });
  };

  //添加多选题
export let multilink = (single, text) => {
    return requst({
      url: "/duoxuan/insertOne",
      method: "post",
      data: {
        ...single,
        a: text[0],
        b: text[1],
        c: text[2],
        d: text[3],
      },
      headers: {
        "Content-type": "application/json; charset=utf-8",
      },
    });
  };
  //添加判断题
  export let judgelink = (single, text) => {
    return requst({
      url: "/panduan/insertOne",
      method: "post",
      data: {
        ...single,
        a: text[0],
        b: text[1],
      },
      headers: {
        "Content-type": "application/json; charset=utf-8",
      },
    });
  };
  //添加填空题
  export let filllink = (single) => {
    return requst({
      url: "/tiankong/insertOne",
      method: "post",
      data: {
        ...single,
      },
      headers: {
        "Content-type": "application/json; charset=utf-8",
      },
    });
  };
  //添加简答题
  export let resumelink = (single) => {
    return requst({
      url: "/jianda/insertOne",
      method: "post",
      data: {
        ...single,
      },
      headers: {
        "Content-type": "application/json; charset=utf-8",
      },
    });
  };

//根据id、学科、题型任意一个查询数据
export let checklink = (checkInfo) => {
  return requst({
    url: "/timu/findAll",
    method: "get",
    params: {
      page: 1,
      limit: 5,
      ...checkInfo,
    },
  });
};
//删除数据
export let dellink = (questionId) => {
  return requst({
    url: `/timu/deleteOne/${questionId}`,
    method: "delete",
  });
};
//预览题目
export let prelink = (questionId) => {
  return requst({
    url: "/timu/yulan/" + questionId,
    method: "get",
  });
};
//班级名称
export let classlink = () => {
  return requst({
    url: "/wyzB",
    method: "get",
  });
};

